/**
 * 加入房间
 */
var JoinRoomWindow = Window.extend({
    /**
     * 数字数组
     * @type {Array}
     */
    _nums: [],
    _ccsFileName: res.JoinRoomWindow_json,
    initWindow:function(){
        this._nums = [];
        this._changeNum();
    },
    _initClickListeners: function () {
        this._super();
        this._clickListeners = {
            '0': '_clickNum',
            '1': '_clickNum',
            '2': '_clickNum',
            '3': '_clickNum',
            '4': '_clickNum',
            '5': '_clickNum',
            '6': '_clickNum',
            '7': '_clickNum',
            '8': '_clickNum',
            '9': '_clickNum',
            'delete': '_clickDel',
            'reset': '_clickReset'
        };
    },
    /**
     * 点击数字
     * @private
     */
    _clickNum: function (sender) {
        if (this._nums.length < 6) {
            this._nums.push(sender.getName());
        }
        if (this._nums.length == 6) {
            showLoading("正在加入房间");
            var roomId = this._nums.join('');
            network.send(MsgCode.JoinRoom, {room_id: roomId});
        }
        this._changeNum();
    },
    /**
     * 点击删除
     * @private
     */
    _clickDel: function () {
        this._nums.pop();
        this._changeNum();
    },
    /**
     * 点击重制
     * @private
     */
    _clickReset: function () {
        this._nums = [];
        this._changeNum();
    },
    /**
     * 改变当前的数字
     * @private
     */
    _changeNum: function () {
        for (var i = 0; i < this._nums.length; i++) {
            var num = this._nums[i];
            this._nodeList['Text_' + i].setString(num);
        }
        for (; i < 6; i++) {
            this._nodeList['Text_' + i].setString('');
        }
    }
});